home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 366_01 / ue311c1.arc / AOSVS.C < prev    next >
C/C++ Source or Header  |  1991-10-11  |  56KB  |  1,925 lines

  1. /*
  2.  * aosvs.c  -  AOS/VS & MV/UX version of the termio.c module
  3.  *
  4.  * The functions in this module deal with the O/S in reading/writing
  5.  * characters from/to the screen.  We also deal with various wiedness things
  6.  * in dealing with the AOS/VS file system such as ACL's and elementsizes.
  7.  * This has been written primarily for AOS/VS but should work for MV/UX as
  8.  * well.  No promises though.
  9.  *
  10.  * AOS/VS and MV/UX are products of Data General Corporation, Westboro MA.
  11.  *
  12.  * Authors:
  13.  *          Daniel Lawrence --- doing MicroEmacs... stuff copied into here...
  14.  *          Douglas Rady ------ most of the rest of the stuff here
  15.  * Credits:
  16.  *          Michael Meissner -- beating Doug over the head with advice and info.
  17.  *                              on AOS/VS "C" compiler.     THANK YOU!!!!!!!!!!
  18.  *          Bill Benedetto
  19.  *          & friends      ---- beta victims, bug finders/fixers
  20.  *          GNU --------------- inspiration, software tools, clean readable BSD
  21.  *                              and USG code examples and interesting comments.
  22.  *
  23.  * Definition: uka = Unixly Known As
  24.  *
  25.  * Revision/Hack History
  26.  *  MicroEMACS v3.<9p,10> AOS/VS History
  27.  *  
  28.  *  3.09.16.00 - 3.09.16.09         ??-???-??           dcr
  29.  *      Before written history.  Suffice to say that .00 - .04 was just the
  30.  *      AOS/VS port from 3.8z, 3.9e, 3.9i and 3.9n with major cleaning up and
  31.  *      rewriting of the AOS/VS stuff.  Sub-revisions 3.09.16.05 - 3.09.16.09
  32.  *      being optimizations and various fixes.
  33.  *      Yawn...
  34.  *
  35.  *  3.09.16.10                      25-Aug-88           dcr
  36.  *      Changed  do_system_end()  in  aosvs.c  to check for execution of a 
  37.  *    macro as basis for not executing an  mlreply("Continue")  call.
  38.  *      Also fixed  stime()  in  aosvs.c  so it just plain worked.
  39.  *      #$&^@*&(+$#!!!!
  40.  *      Also added  REPLYNL  in  estruct.h  and made use of CR or NL in the
  41.  *      mlreply()  routine in  input.c  compile time conditional.
  42.  *
  43.  *  3.09.16.11                      13-Sep-88           dcr
  44.  *      Start of written hisory.  This is a momentous event in the course of
  45.  *      AOS/VS MicroEMACS history: doug writes some change doc.!!! Yeah!!!
  46.  *      Changed several functions to force the  $builtin  version as a trade of
  47.  *      more code size for more speed (usually defaulted to $builtin anyway...).
  48.  *
  49.  *  3.09.16.12                      14-Sep-88           dcr
  50.  *      Recompiled with revision 4.00 of AOS/VS C.  A miracle...
  51.  *
  52.  *  3.09.16.13                      12-Oct-88           dcr
  53.  *      Changed to have the temporary file for pipecmd() be created in a system
  54.  *      wide temporary file directory known as :TMP, uka /tmp.  You paranoids
  55.  *      can create :TMP as a CPD with max. size of 2048 blocks and an ACL of
  56.  *      +,WE and you should be able to relax a nibble.
  57.  *      Creates temp. file with ACL of  username,OWAR
  58.  *
  59.  *  3.09.16.14                      13-Oct-88           dcr
  60.  *      Put in MCA's hack to reduce memory consumption when VIEWing a file.
  61.  *      Modified  lalloc()  in line.c  Test case of paru.h saved 27 2Kb pages.
  62.  *
  63.  *  3.10.00.00                      09-Nov-88           dcr
  64.  *      Begin code porting for 3.10 BETA.
  65.  *
  66.  *  3.10.00.01                      20-Dec-88           dcr
  67.  *      Implemented multi-language messages in  aosvs.c  per 3.10 BETA.
  68.  *
  69.  *  3.10.00.02                      26-Dec-88           dcr
  70.  *      Tracked down some un-documented runtime optimizations and got
  71.  *      a working version. Also resolved timeset() references.
  72.  *
  73.  *  3.10.00.03                      17-Jan-89           dcr
  74.  *      Cleaned up for shipping to Dan.  Put in some missing code for input.c
  75.  *
  76.  *  3.10.00.04                      17-Jan-89           dcr
  77.  *      Put in some optimizations regarding TTflush() and ostring() in the
  78.  *      bind.c, input.c and aosvs.c files.  This freed 2Kb... but not for long.
  79.  *
  80.  *  3.10.00.05                      17-Jan-89           dcr
  81.  *      Some memory optimization in  exec.c  and  input.c for small regain.
  82.  *
  83.  *  3.10.00.06 - 3.10.00.27     02-Mar-89 - 10-Mar-89   dcr
  84.  *      Various changes. Cleaned up the AOS/VS changes in other modules so 
  85.  *      we actually work right.  Added conditionals for using either BSD or
  86.  *      USG console i/o (BSD doesn't seem to work).  Reclaimed about 4Kb of 
  87.  *      memory in various places and made some of these optimizations compile
  88.  *      time conditional. We are still using .890+ ms to start up intead of the
  89.  *      .520+ ms that we took with 3.9p. Not much hope there... but...
  90.  *      Various tweaks here and there.  Added the skip of nulls when reading in
  91.  *      a file (most unpleasant results if we don't).  Lost some memory to the
  92.  *      USG console i/o stuff.  Threw out the BSD console i/o stuff, sigh....
  93.  *
  94.  *  3.10.00.28                      10-Mar-89           dcr
  95.  *      Stuck in the  aosvs$unix_to_aosvs_path()  routine to replace the code
  96.  *      in resolve_pathname().  The new routine does a fairly complete job of
  97.  *      converting Unix(tm) pathnames to AOS/VS format. It also handles the 
  98.  *      Ms-Dog '\' path seperator.
  99.  *  
  100.  *  3.10.00.29                      16-Mar-89           dcr
  101.  *      Changed pathname expansion to be invisible to user.  Required changes
  102.  *      to  fileio.c  to #if AOSVS  replace the fopen() calls with our xxfopen()
  103.  *      call which does the pathname expansion.  Allowed removal of all the
  104.  *      related to the EXPPATH define.  Also changed several routines here.
  105.  *      Allows user to reference buffer & file names w/o "unexpanding" the 
  106.  *      orginal pathname.
  107.  *      Diff'd & sent to Dan.
  108.  *
  109.  */
  110.  
  111. #nolist
  112. #include        <stdio.h>           /* get the usual */
  113. #list
  114. #include        "estruct.h"         /* get the MicroEMACS stuff */
  115.  
  116. #ifdef  AOSVS | MV_UX               /* should this be done? */
  117.  
  118. #define dashertermdef   1           /* might not be used any more */
  119.  
  120. #nolist
  121. #include        "edef.h"            /* get the MicroEMACS extern's */
  122. #include        "elang.h"
  123. #list
  124.  
  125. /* There is no kitchen sink in C so we can't include it. Maybe in C++... */
  126. #nolist
  127. #include    <paru.h>                /* AOS/VS system mnemonics */
  128. #include    <sysid.h>               /* AOS/VS system call mnemonics */
  129. #include    <packets/characteristics.h> /* sys call packet for terminal char.*/
  130. #include    <packets/create.h>      /* sys call packet to create files */
  131. #include    <packets/filestatus.h>  /* sys call packet to get file info */
  132. #include    <packets/misc.h>        /* misc. sys call packets (?SYSPRV) */
  133.  
  134. /* And now... the Unix(tm) stuff... */
  135. #include    <fcntl.h>               /* terminal file control stuff */
  136. #include    <signal.h>              /* the signals... */
  137. #include    <termio.h>              /* more terminal control stuff */
  138. #list
  139.  
  140. /*
  141.     Variables!!!   Functions!!!  Externals!!!!
  142. */
  143. struct  termio  old_in_termio;  /* original stdin terminal characteristics */
  144. struct  termio  new_in_termio;  /* stdin characteristics to use inside */
  145.  
  146. int kbdpoll;                    /* type ahead polling flag      */
  147. int kbdflgs;                    /* saved keyboard fd flags      */
  148. int kbdqp;                      /* there is a char in kbdq      */
  149. char kbdq;                      /* char we've already read      */
  150.  
  151. /*
  152.     some D.G. supplied AOS/VS & MV/UX specific functions
  153.  
  154.     _toaos_fid() - changes UNIX(tm)  pathname to AOS/VS pathname (Thank you!)
  155.     traceback() - calls the ?SNAP LANG_RT routine for error traceback
  156. */    
  157. /*extern int  _toaos_fid(char*, char* );*/
  158. extern VOID traceback(int );
  159.  
  160. /*
  161.     This is how we make an MV/Eclipse accumulator in C with almost all options.
  162. */
  163. union accumulator {                 /* dearly beloved, we are gathered here...*/
  164.     unsigned long * ptr;            /* pointer to unsigned long (generic) */
  165.     char *          cptr;           /* pointer to char */
  166.     unsigned int  * pint;           /* pointer to unsigned int */
  167.     unsigned short *psht;           /* pointer to short */
  168.     unsigned long   ulng;           /* unsigned lon